package com.dinzeer.godfox.data;

import com.dinzeer.godfox.Godfox;
import com.dinzeer.godfox.regsiter.GBCreativeTab;
import com.dinzeer.godfox.regsiter.GBSlashartRegsitry;
import com.dinzeer.godfox.regsiter.GBSpecialEffectsRegistry;
import mods.flammpfeil.slashblade.item.SwordType;
import mods.flammpfeil.slashblade.registry.SlashArtsRegistry;
import mods.flammpfeil.slashblade.registry.slashblade.EnchantmentDefinition;
import mods.flammpfeil.slashblade.registry.slashblade.PropertiesDefinition;
import mods.flammpfeil.slashblade.registry.slashblade.RenderDefinition;
import mods.flammpfeil.slashblade.registry.slashblade.SlashBladeDefinition;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraftforge.registries.ForgeRegistries;

import java.util.List;

public class GBBuiltInRegsitry {
    //妖刀「神狐」
    public static final ResourceKey<SlashBladeDefinition> GODFOX=register("godfox");
    //锈迹斑斑的刀
    public static final ResourceKey<SlashBladeDefinition> RUSTGODFOX=register("rustgodfox");
    //木鞘「刃条」
    public static final ResourceKey<SlashBladeDefinition> stickgodfox=register("stickgodfox");
    //御神灵刀「神狐」
    public static final ResourceKey<SlashBladeDefinition> NEOGODFOX=register("neogodfox");
    //木鞘「神狐」
    public static final ResourceKey<SlashBladeDefinition> WHITEGODFOX=register("whitegodfox");
    //御神刀「神狐」
    public static final ResourceKey<SlashBladeDefinition> TRUEGODFOX=register("truegodfox");
    //妖魔刀「血狐」
    public static final ResourceKey<SlashBladeDefinition> truebloodfox=register("truebloodfox");
    public static void registerAll(BootstapContext<SlashBladeDefinition> bootstrap) {
        bootstrap.register(
                GODFOX, new SlashBladeDefinition(Godfox.prefix("godfox"),
                        RenderDefinition.Builder.newInstance()
                                .textureName(Godfox.prefix("model/named/godfox/texture.png"))
                                .modelName(Godfox.prefix("model/named/godfox/model.obj"))
                                .effectColor(15906304)
                                .build(),
                        PropertiesDefinition.Builder.newInstance()
                                .defaultSwordType(List.of(SwordType.BEWITCHED))
                                .slashArtsType(GBSlashartRegsitry.MP.getId())
                                .baseAttackModifier(18)
                                .maxDamage(2000)
                                .build(),
                        List.of(
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.SHARPNESS), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.FIRE_PROTECTION), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.FALL_PROTECTION), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.UNBREAKING), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.RESPIRATION), 1)

                        ),
                        GBCreativeTab.Slashblade.getId()
                ));

        bootstrap.register(
                RUSTGODFOX, new SlashBladeDefinition(Godfox.prefix("rustgodfox"),
                        RenderDefinition.Builder.newInstance()
                                .textureName(Godfox.prefix("model/named/rustgodfox/texture.png"))
                                .modelName(Godfox.prefix("model/named/rustgodfox/model.obj"))
                                .build(),
                        PropertiesDefinition.Builder.newInstance()
                                .defaultSwordType(List.of(SwordType.BEWITCHED))
                                .baseAttackModifier(5)
                                .maxDamage(2000)
                                .build(),
                        List.of(),
                        GBCreativeTab.Slashblade.getId()
                ));

        bootstrap.register(
                stickgodfox, new SlashBladeDefinition(Godfox.prefix("stickgodfox"),
                        RenderDefinition.Builder.newInstance()
                                .textureName(Godfox.prefix("model/named/stickgodfox/texture.png"))
                                .modelName(Godfox.prefix("model/named/stickgodfox/model.obj"))
                                .build(),
                        PropertiesDefinition.Builder.newInstance()
                                .defaultSwordType(List.of(SwordType.BEWITCHED))
                                .baseAttackModifier(10)
                                .slashArtsType(SlashArtsRegistry.DRIVE_HORIZONTAL.getId())
                                .maxDamage(2000)
                                .build(),
                        List.of(),
                        GBCreativeTab.Slashblade.getId()
                ));

        bootstrap.register(
                NEOGODFOX, new SlashBladeDefinition(Godfox.prefix("neogodfox"),
                        RenderDefinition.Builder.newInstance()
                                .textureName(Godfox.prefix("model/named/neogodfox/texture.png"))
                                .modelName(Godfox.prefix("model/named/neogodfox/model.obj"))
                                .effectColor(15906304)
                                .build(),
                        PropertiesDefinition.Builder.newInstance()
                                .addSpecialEffect(GBSpecialEffectsRegistry.NeoBlessing.getId())
                                .addSpecialEffect(new ResourceLocation("foxextra","foxbling"))
                                .slashArtsType(GBSlashartRegsitry.GodFoxBoost.getId())
                                .defaultSwordType(List.of(SwordType.BEWITCHED))
                                .baseAttackModifier(18)
                                .maxDamage(2000)
                                .build(),
                        List.of(new EnchantmentDefinition(getEnchantmentID(Enchantments.SHARPNESS), 10),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.KNOCKBACK), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.FIRE_PROTECTION), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.FALL_PROTECTION), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.UNBREAKING), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.RESPIRATION), 1)
                        ),
                        GBCreativeTab.Slashblade.getId()
                ));

        bootstrap.register(
                WHITEGODFOX, new SlashBladeDefinition(Godfox.prefix("whitegodfox"),
                        RenderDefinition.Builder.newInstance()
                                .textureName(Godfox.prefix("model/named/whitegodfox/texture.png"))
                                .modelName(Godfox.prefix("model/named/whitegodfox/model.obj"))
                                .build(),
                        PropertiesDefinition.Builder.newInstance()
                                .defaultSwordType(List.of(SwordType.BEWITCHED))
                                .baseAttackModifier(12)
                                .slashArtsType(SlashArtsRegistry.DRIVE_VERTICAL.getId())
                                .maxDamage(2000)
                                .build(),
                        List.of(),
                        GBCreativeTab.Slashblade.getId()
                ));

        bootstrap.register(
                TRUEGODFOX, new SlashBladeDefinition(Godfox.prefix("truegodfox"),
                        RenderDefinition.Builder.newInstance()
                                .textureName(Godfox.prefix("model/named/truegodfox/texture.png"))
                                .modelName(Godfox.prefix("model/named/truegodfox/model.obj"))
                                .effectColor(15906304)
                                .build(),
                        PropertiesDefinition.Builder.newInstance()
                                .addSpecialEffect(GBSpecialEffectsRegistry.BLESSING.getId())
                                .slashArtsType(GBSlashartRegsitry.PROWESS.getId())
                                .defaultSwordType(List.of(SwordType.BEWITCHED))
                                .baseAttackModifier(22)
                                .maxDamage(2000)
                                .build(),
                        List.of(new EnchantmentDefinition(getEnchantmentID(Enchantments.SHARPNESS), 5),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.KNOCKBACK), 2),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.BLOCK_FORTUNE), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.MOB_LOOTING), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.FIRE_PROTECTION), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.FALL_PROTECTION), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.UNBREAKING), 3),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.RESPIRATION), 1)
                        ),
                        GBCreativeTab.Slashblade.getId()
                ));
        bootstrap.register(
                truebloodfox, new SlashBladeDefinition(Godfox.prefix("truebloodfox"),
                        RenderDefinition.Builder.newInstance()
                                .textureName(Godfox.prefix("model/named/demonfox/demonfox.png"))
                                .modelName(Godfox.prefix("model/named/truegodfox/model.obj"))
                                .effectColor(16711697)
                                .build(),
                        PropertiesDefinition.Builder.newInstance()
                                .addSpecialEffect(GBSpecialEffectsRegistry.BloodFoxCurse.getId())
                                .slashArtsType(GBSlashartRegsitry.BloodWaveEdge.getId())
                                .defaultSwordType(List.of(SwordType.BEWITCHED))
                                .baseAttackModifier(18)
                                .maxDamage(2000)
                                .build(),
                        List.of(new EnchantmentDefinition(getEnchantmentID(Enchantments.SHARPNESS), 5),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.KNOCKBACK), 5),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.BLOCK_FORTUNE), 5),
                                new EnchantmentDefinition(getEnchantmentID(Enchantments.MOB_LOOTING), 5)
                        ),
                        GBCreativeTab.Slashblade.getId()
                ));
    }



    private static ResourceKey<SlashBladeDefinition> register(String id) {
        return ResourceKey.create(SlashBladeDefinition.REGISTRY_KEY, Godfox.prefix(id));
    }
    static ResourceLocation getEnchantmentID(Enchantment enchantment) {
        return ForgeRegistries.ENCHANTMENTS.getKey(enchantment);
    }
}
